﻿/********************************************************************************
** @ Date:2024/08/01
** @ Author: WeiXiaoYu
** @ Description: 日志单例类
** @ Version:1.0.0
** @ Fun:
********************************************************************************/
#ifndef CLogOper_H
#define CLogOper_H
#include "LogModule.h"

//报警等级:1运行 2正常 3报警 4错误 5硬件故障
enum ELogType
{
    enLogTypeRun = 1,		//运行
    enLogTypeInfo,		//正常
    enLogTypeAlarm,		//报警
    enLogTypeError,		//错误
    enLogTypeHardWare	//硬件故障
};

struct SExecLog
{
    int            m_nAlarmLevel;       //报警等级:1运行 2正常 3报警 4错误 5硬件故障
    QString        m_sObject;           //对象名称
    QString        m_sLogDesc;          //日志描述

	SExecLog()
	{
        m_nAlarmLevel = 1;
        m_sObject = "TestObj";
        m_sLogDesc = "TestDesc";
	}
};

class CLogOper
{
public:
	static CLogOper& instance()
	{
		static CLogOper instance;
		return instance;
	}

public:
    void addLogModule(QString sName,LogModule *pLogModule);//将传入的日志控件指针统一管理

    void addLogMsg(QString sName, SExecLog sExecLog);//添加日志

private:
	CLogOper();
	~CLogOper();
	
    QMap<QString, LogModule*> m_mapLogModule;//QString为类名 值为日志控件的指针
};
#endif
